import React from "react";

const Addguest = () => {


    const add = async (values: any) => {
        
        values.busid = React.Business.id
        
        // 请求接口
        var result = await React.HTTP.post('/guest/add',values)

        if(result.code == 0){
            React.UI.Toast.show({
                icon: 'fail',
                content: result.msg
            })
        }else{
            React.UI.Toast.show({
                icon: 'success',
                content: result.msg
            })

            React.navigate(-1)
        }
    }

    return (
        <>
            <React.UI.NavBar back='返回' onBack={() => { React.navigate(-1) }}>
                添加入住人
            </React.UI.NavBar>

            <React.UI.Form
                name='form'
                layout='horizontal'
                mode='card'
                onFinish={add}
                footer={
                    <React.UI.Button block type='submit' color='primary' size='large'>
                        提交
                    </React.UI.Button>
                }
            >

                <React.UI.Form.Item name="nickname" label="入住人姓名" rules={[{ required: true }]}>
                    <React.UI.Input placeholder="请输入入住人姓名" />
                </React.UI.Form.Item>

                <React.UI.Form.Item name="mobile" label="手机号" rules={[{ required: true }, { pattern: /^1[3456789]\d{9}$/, message: '手机号格式不对' }]}>
                    <React.UI.Input placeholder="请输入手机号" />
                </React.UI.Form.Item>

                <React.UI.Form.Item name="sex" label="性别" rules={[{ required: true }]}>
                    <React.UI.Radio.Group>
                        <React.UI.Space direction='vertical'>
                        <React.UI.Radio value='1'>男</React.UI.Radio>
                        <React.UI.Radio value='2'>女</React.UI.Radio>
                        </React.UI.Space>
                    </React.UI.Radio.Group>
                </React.UI.Form.Item>
            </React.UI.Form>
        </>
    )
}


export default Addguest;